<template>
  <!--招采管理-物资招采列表-应标结果详情弹窗-表单-->
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :model="model" :rules="validatorRules">
        <!-- 主表单区域 -->
        <a-row class="form-row" :gutter="16">
          <a-col :lg="8">
            <a-form-model-item label="招标名称" prop="name">
              <a-input  v-model="model.name" placeholder="请输入招标名称" />
            </a-form-model-item>
          </a-col>
          <a-col :lg="8">
            <a-form-model-item label="所属项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="project">
              <a-input  v-model="model.project" placeholder="请输入项目"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :lg="8">
            <a-form-model-item label="结标时间" prop="traneIncTime">
              <j-date  showTime valueFormat="YYYY-MM-DD" v-model="model.traneIncTime" />
            </a-form-model-item>
          </a-col>
          <a-col :span="18" style="margin-right: -250px">
          <a-form-model-item label="技术要求(上传文件包)" prop="fileList">
            <j-upload v-model="model.technicalRequirements"></j-upload>
          </a-form-model-item>
        </a-col>
          <!-- <a-col :span="6">
            <a-form-model-item label="" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-button type="primary" @click="handleSupplier" icon="search" style="margin-left: 8px"
                >选择供应商</a-button
              >
            </a-form-model-item>
          </a-col> -->
        </a-row>

        <!-- 子表单区域 -->
        <a-tabs defaultActiveKey="1">
          <a-tab-pane tab="招标信息" key="1">
            <div>
              <a-row type="flex" style="margin-bottom: 10px" :gutter="16">

                <a-col :span="6">物资名称</a-col>
                <a-col :span="6">规格/型号</a-col>
                <a-col :span="6">单位</a-col>
                <a-col :span="6">数量</a-col>

              </a-row>

              <a-row type="flex" style="margin-bottom: 10px" :gutter="16"
                v-for="(item, index) in model.biddingMaterialsList" :key="index">

                <a-col :span="6">
                  <a-form-model-item>
                    <a-input :options="StandardList" v-model="item.platformProductName" placeholder="物资名称"
                      ></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="6">
                  <a-form-model-item>
                    <a-input  :options="modelList" v-model="item.model" placeholder="规格/型号"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="6">
                  <a-form-model-item>
                    <a-input  v-model="item.unit" :options="unit" placeholder="单位"></a-input>
                  </a-form-model-item>
                </a-col>
                <a-col :span="6">
                  <a-form-model-item>
                    <a-input  v-model="item.num" placeholder="数量"></a-input>
                  </a-form-model-item>
                </a-col>

              </a-row>
              <!-- <a-button type="dashed" style="width: 98%; margin-top: 10px" @click="addRcruit">
                <a-icon type="plus" /> 添加招标信息
              </a-button> -->

              <!-- <a-col :span="24" style="margin-top: 20px">
                <div class="table-page-search-wrapper">
                  <a-form layout="inline" @keyup.enter.native="searchQuery">
                    <a-row :gutter="24">
                      <a-col :md="6" :sm="12">
                        <a-form-item label="名称">

                          <j-input placeholder="输入名称模糊查询" v-model="queryParam.name"></j-input>
                        </a-form-item>
                      </a-col>
                      <a-col :md="6" :sm="8">
                        <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                          <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                          <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px"
                            >重置</a-button
                          >
                        </span>
                      </a-col>
                    </a-row>
                  </a-form>
                </div>
                <a-table
                  ref="table"
                  size="middle"
                  :scroll="{ x: true }"
                  bordered
                  rowKey="id"
                  :columns="columns"
                  :dataSource="dataSource"
                  :pagination="ipagination"
                  :loading="loading"
                  :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
                  class="j-table-force-nowrap"
                  @change="handleTableChange"

                >
                </a-table>
              </a-col> -->
            </div>
          </a-tab-pane>
        </a-tabs>
      </a-form-model>
    </j-form-container>
    <!-- <Wt-Public-Price-Supplier-Modal ref="modalForm2" @ok="modalFormOk"></Wt-Public-Price-Supplier-Modal> -->
  </a-spin>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import JDate from '@/components/jeecg/JDate'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { axios } from '@/utils/request'
import signMd5Utils from '@/utils/encryption/signMd5Utils'
// import WtPublicPriceSupplierModal from './WtPublicBiddingPriceSupplierModal.vue'
// import WtPublicPriceSupplierForm from './WtPublicBiddingPriceSupplierForm.vue'
export default {
  name: 'WtPublicBiddingRecruitForm',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    JDate,

    // MaterialSupplier,
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    },
    id: {
      type: String
    }
  },

  data() {
    return {
      id:'',
      LevelOneList: [],
      LevelTwoList: [],
      LevelThreeList: [],
      title: '操作',
      visible: false,
      model: {
        biddingMaterialsList: [
          {
            platformProductName: '',
            num: '',
            model: '',
            unit: '',

          },
        ],
        categoryOneId: '',
        categoryTwoId: '',
        categoryThreeId: '',
        project: '',
        orderDate: '',
        technicalRequirements: [],
      },

      treeData: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
        //  name: [{ required: true, message: '招采名称不能为空', trigger: 'blur' }],
      },
      url: {
        add: '',
        edit: '/bidding/wtPublicBidding/edit',
        orderCustomerList: '/test/jeecgOrderMain/queryOrderCustomerListByMainId',
        orderTicketList: '/test/jeecgOrderMain/queryOrderTicketListByMainId',
        list: '/bidding/wtPublicBiddingMaterials/queryList'
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: { type: '0', publicBiddingId: this.id },
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: 'id',
          align: 'center',
          dataIndex: 'id',
        },
        {
          title: '名称',
          align: 'center',
          dataIndex: 'name',
        },

        {
          title: '联系人',
          align: 'center',
          dataIndex: 'relation',
        },
        {
          title: '电话',
          align: 'center',
          dataIndex: 'phone',
        },
        {
          title: '地址',
          align: 'center',
          dataIndex: 'address',
        },
        {
          title: '评分',
          align: 'center',
          dataIndex: 'score',
        },
      ],
    }
  },
  created() {
    // console.log('111', this.id)
  },
  computed: {
    formDisabled() {
      return this.disabled
    }
  },
  methods: {
    initDictConfig() { },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'name', text: '名称', dictCode: '' })
      fieldList.push({ type: 'int', value: 'type', text: '0经营产品1施工', dictCode: '' })
      fieldList.push({ type: 'string', value: 'relation', text: '联系人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'phone', text: '电话', dictCode: '' })
      fieldList.push({ type: 'string', value: 'address', text: '地址', dictCode: '' })
      fieldList.push({ type: 'string', value: 'score', text: '评分', dictCode: '' })
      this.superFieldList = fieldList
    },
    add() {
      this.edit({})
    },
    edit(record) {

      let url  = "/bidding/wtPublicBiddingMaterials/queryList"
      let parameter  = {
        publicBiddingId: record.id
      }

      let sign = signMd5Utils.getSign(url, parameter);

      let signHeader = {"X-Sign": sign,"X-TIMESTAMP": signMd5Utils.getTimestamp()};

      axios({
        url: url,
        method:'get' ,
        params: parameter,
        headers: signHeader
      }).then((res) => {
        this.model.biddingMaterialsList = res.result

      })
      this.model = Object.assign(
        {
          biddingMaterialsList: [{}],
        },
        record
      )

      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
    },

    handleCancel() {
      this.close()
    },
    addRcruit() {
      this.model.biddingMaterialsList.push({})

      this.$forceUpdate()
    },
    delRcruit(index) {
      this.model.biddingMaterialsList.splice(index, 1)
      this.$forceUpdate()
      this.model.biddingMaterialsList.model =
        this.model.biddingMaterialsList.num =
        this.model.biddingMaterialsList.unit =
        this.model.categoryOneId =
        this.model.categoryTwoId =
        this.model.categoryThreeId =
        this.model.biddingMaterialsList.platformProductName =
        ''
    },
  },
}
</script>
<style scoped>
.ant-btn {
  padding: 0 10px;
  margin-left: 3px;
}

.ant-form-item-control {
  line-height: 0px;
}

/** 主表单行间距 */
.ant-form .ant-form-item {
  margin-bottom: 10px;
}

/** Tab页面行间距 */
.ant-tabs-content .ant-form-item {
  margin-bottom: 0px;
}
</style>
